#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
const int N=1e5+5;
int T,n,m,L,t,t2,ans1,ans2;
double V,d[N],v[N],a[N],b[N],p[N];
int an[N];
unordered_map<int,int> ma;
int main(){
    //freopen("detect.in","r",stdin);
    //freopen("detect.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d%lf",&n,&m,&L,&V);
        memset(b,0.0,sizeof(b));
        ans1=0,ans2=0;
        for(int i=1;i<=n;i++)
            scanf("%lf%lf%lf",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++)
            scanf("%lf",&p[i]);
        //for(int i=1;i<=n;i++)
            //cout<<b[i]<<' ';
        for(int i=1;i<=n;i++){
            if((v[i]+a[i])<=V&&v[i]<=V)
                continue;
            else{
                if(a[i]==0)
                    b[i]=0;
                else
                    b[i]=(V*V-v[i]*v[i])/(a[i]*2);
            }
            //cout<<"i="<<i<<" d+b="<<d[i]+b[i]<<endl;
        }
        for(int i=1;i<=n;i++){
            if((v[i]+a[i])<=V&&v[i]<=V)
                continue;
            if(v[i]<=V&&(v[i]+a[i])>V){
                t=upper_bound(p+1,p+n+1,(d[i]+b[i]))-p;
                //cout<<t<<endl;
                an[t]++;
            }
            if(v[i]>V&&(v[i]+a[i])<=V){
                t=upper_bound(p+1,p+n+1,d[i])-p;
                t2=upper_bound(p+1,p+n+1,(d[i]+b[i]))-p;
                if(t==t2)
                    continue;
                else
                    an[t]++,an[t2]--;
            }
            if(v[i]>V){
                t=lower_bound(p+1,p+n+1,d[i])-p;
                an[t]++;
            }
        }
        ans1=0,ans2=0;
        for(int i=1;i<=m;i++){
            ans1+=an[i];
            cout<<an[i]<<' ';
            if(an[i]>0)
                ans2++;
        }
        printf("%d %d\n",ans1,m-ans2);
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
